package com.yf.stat.modules.exam.dto;

import com.yf.ability.excel.annotation.ExcelField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
* <p>
* 考试总体统计数据传输类
* </p>
*
* @author 聪明笨狗
* @since 2020-09-11 11:10
*/
@Data
@ApiModel(value="考试总体统计", description="考试总体统计")
public class StatExamTotalDTO implements Serializable {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "ID", required=true)
    private String id;

    @ExcelField(title = "部门名称")
    @ApiModelProperty(value = "部门名称", required=true)
    private String title;

    @ApiModelProperty(value = "考试ID")
    private String examId;

    @ExcelField(title = "应考人数")
    @ApiModelProperty(value = "应考人数")
    private Integer totalUser;

    @ExcelField(title = "实考人数")
    @ApiModelProperty(value = "实考人数")
    private Integer actualUser;

    @ExcelField(title = "通过用户")
    @ApiModelProperty(value = "通过用户")
    private Integer passUser;

    @ApiModelProperty(value = "缺考人数")
    private Integer missUser;

    @ExcelField(title = "通过率%", sort = 3)
    private Integer passRate;


    /**
     * 缺考人数
     * @return
     */
    public Integer getMissUser(){
        if(this.totalUser==null || this.totalUser==0){
            return 0;
        }

        if(this.actualUser==null || this.actualUser==0){
            return totalUser;
        }

        return this.totalUser - this.actualUser;
    }

    /**
     * 人数
     * @return
     */
    public Integer getPassRate(){

        // 无人通过
        if(passUser==null || passUser.equals(0)){
            return 0;
        }

        // 未指定的情况
        if(totalUser == null || totalUser.equals(0)){
            if(actualUser!=null && !actualUser.equals(0)){
                return passUser*100 / actualUser;
            }
        }else{
            return passUser*100 / totalUser;
        }

        return 0;
    }
}
